package com.lichuandi.future;

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.schedulers.Schedulers;

public class RxJavaExample {
    public static void main(String[] args) {
        Observable.fromCallable(() -> {
                    Thread.sleep(1000);
                    return "RxJava Result";
                })
                .subscribeOn(Schedulers.io()) // 指定IO线程执行
                .observeOn(Schedulers.single()) // 结果处理在主线程
                .subscribe(
                        result -> System.out.println(result),
                        Throwable::printStackTrace
                );
    }
}